using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Runtime.Serialization;

namespace Shrapnel.Areas
{
	/// <summary>
	/// A box-shaped area
	/// </summary>
	[DataContract()]	
	public class Box : Part
	{
		/// <summary>
		/// The area of the box
		/// </summary>
		[DataMember(Name="Area")]
		private RectangleF area = new RectangleF(0, 0, 0, 0);

		/// <summary>
		/// Access to the size of the box
		/// </summary>
		public RectangleF BoxArea
		{
			get { return area; }
			set { area = value; }
		}

		/// <summary>
		/// Move this part with the provided delta
		/// </summary>
		/// <param name="delta">Offset to apply</param>
		public override void Move(PointF delta)
		{
			area.X += delta.X;
			area.Y += delta.Y;
		}


		/// <summary>
		/// Calculate the bounding box for this part
		/// </summary>
		/// <returns></returns>
		public override BoundingBox GetBoundingBox()
		{
			return new BoundingBox(area);
		}


		/// <summary>
		/// Precise overlapping check
		/// </summary>
		/// <param name="bbox">A worlspace bbox</param>
		/// <returns>Return true when this part overlaps with the given bbox</returns>
		public override bool OverlapsWith(BoundingBox bbox)
		{
			return GetBoundingBox().OverlapsWith(bbox);

		}
	}
}
